package practice.library.gremlin_scala.trial.friends_group.model

import gremlin.scala.{label, _}
import org.joda.time.DateTime

import scala.util.{Failure, Success, Try}

/**
  * Created by lovepocky on 16/7/18.
  */
object Vertex {

	object label {
		val person = "person"
		val article = "article"
		//val hotel = "hotel"
		//val shopping = "shopping"

		val pointer_article = "pointer_article"
	}

	def transform2CC(vertex: Vertex): Try[_] = {
		vertex.label() match {
			case label.`person` => Success(vertex.toCC[person])
			case label.`article` => Success(vertex.toCC[article])
			//case label.hotel => Success(vertex.toCC[hotel])
			//case label.shopping => Success(vertex.toCC[shopping])
			case _ => Failure(new Exception("label not match"))
		}
	}

	@label(label.person)
	case class person(name: String, updateTime: DateTime = DateTime.now())

	@label(label.article)
	case class article(title: String, content: String, updateTime: DateTime = DateTime.now(), timeStamp: Long, authorId: Long)


	/** Index Vertex */
	@label(label.pointer_article)
	case class pointer_article(ownerId: Long, timeStamp: Long)

}
